#!/bin/bash
#
# Sets system context information
#
# Author:   Dr. Mike Murphy (mmurphy2@coastal.edu)
# Revision: 18 November 2012
#
#   Copyright 2012-2013 Coastal Carolina University
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#


## p_cmd_set_context_help
##
## Echoes help information for the set_context command. Returns 0.
##
function p_cmd_set_context_help() {
	cat << EOF
Usage: pulley set_context <item> <value>

This command sets the value of an item within Pulley system context.

Valid item names may contain the letters a-z or A-Z, digits 0-9, underscore
_, and slashes /. If slashes are used, context information can be stored in
a tree.
EOF
	return 0
}


## p_cmd_set_context_summary
##
## Echoes summary information for the set_context command. Returns 0.
##
function p_cmd_set_context_summary() {
	echo "Sets context information"
	return 0
}


## p_cmd_set_context <item> <value>
##
## Implements the Pulley set_context command. Sets the context path <item>
## to <value>. Returns 0 on success, non-zero on failure.
##
function p_cmd_set_context() {
	local status=0
	if [[ $# -ne 1 ]]; then
		echo "ERROR: Context name and value must be specified"
		status=2
	else
		set_context "$1" "$2"
		status=$?
	fi
	return ${status}
}
